﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Loki.Core.Test
{
    [TestFixture]
    public class ErrorManagerTest : AssertionHelper
    {
        public LokiMockObject TestMock { get; private set; }

        [SetUp]
        public void SetUp()
        {
            TestMock = new LokiMockObject();
        }

        [Test]
        public void InvalidErrorCodeStructure()
        {
            Expect(
                    new TestDelegate(TestMock.ThrowTOO_001),
                    Throws.InstanceOf<LokiException>().With.Property("Code").Property("Code").EqualTo("TOO_001")
            );
        }

        [Test]
        public void InvalidNoMapper()
        {
            Expect(
                    new TestDelegate(TestMock.ThrowTOO_002),
                    Throws.InstanceOf<LokiException>().With.Property("Code").Property("Code").EqualTo("TOO_002")
            );
        }

        [Test]
        public void UnknownMessage()
        {
            Expect(
                    new TestDelegate(TestMock.ThrowWithUnknowErrorMessage),
                    Throws.InstanceOf<LokiException>().With.Property("Code").Property("Message").EqualTo("#UNKNOWN ERROR MESSAGE#")
            );
        }

        [Test]
        public void StdMessage()
        {
            Expect(
                    new TestDelegate(TestMock.ThrowWithMessage),
                    Throws.InstanceOf<LokiException>().With.Property("Code").Property("Message").EqualTo("Test")
            );
        }
    }
}
